package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

public interface UserMapper {
    @Select("select * from student")
    List<User> findAll();

    @Update("INSERT INTO `student`(`id`, `name`, `address`, `age`, `sex`, `phone`) VALUES (#{id},#{name},#{address},#{age},#{sex},#{phone});")
    @Transactional
    void save(User user);

    @Delete("delete from student where id = #{id}")
    @Transactional
    void deleteById(Long id);
}
